package com.ysd.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

import com.ysd.entity.FenLeiBiao;
import com.ysd.util.DBManager;

public class FeiLeiBiaoIdDaoImpl {
	/**
	 * 通过分类表的chanpinId查询类别
	 * @param id
	 * @return
	 */
	public ArrayList<FenLeiBiao> getFenLeiBiao(int id){
		ArrayList<FenLeiBiao> list=new ArrayList<FenLeiBiao>();
		Connection conn=DBManager.getConnection();
		Statement st=null;
		ResultSet rs=null;
		try {
			 st=conn.createStatement();
			String sql="SELECT * FROM fenleibiao where chanpinId="+id;
			 rs=st.executeQuery(sql);
			while(rs.next()) {
				FenLeiBiao flb=new FenLeiBiao(rs.getInt("chanPinId"), rs.getString("leiMing"));
				list.add(flb);
			}
			return list;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}finally {
			DBManager.closeAll(conn, st, rs);
		}
	}
}


